import { ApiResponse, Channel } from '@/types/data'
import { RootThunkAction } from '@/types/store'
import request from '@/utils/request'

//获取用户的频道列表数据

export const getUserChannel = (): RootThunkAction => {
  return async dispatch => {
    const res = await request.get<ApiResponse<{ channels: Channel[] }>>('user/channels')
    console.log(res.data.data.channels)
    dispatch({
      type: 'home/saveUserChannel',
      payload: res.data.data.channels,
    })
  }
}
